<?php

set_time_limit(0);
include '../../../common.inc.php';
// 开始处理时间: 03-21:13:30
//exit();
if (!isset($start)) {
	$start =0;
}
var_dump($start);
if (!isset($end)) {
	exit('please insert $end 的 值!');
} else {
	$end = intval($end);
}
var_dump($end);

$sql = "select m.itemid, d.content from xd_manual m, xd_manual_data d where m.itemid>$start and m.itemid<=$end and m.itemid=d.itemid order by m.itemid ASC limit 90 ";
var_dump($sql);
$arr = $db->getAll($sql);
//var_dump($arr);exit();
if (!$arr) {
	exit('Handle in:"'.$start. '", Handle Over!');
}
foreach($arr as $k => $v) {
	if ($v['content']) {
		preg_match_all('/(<img.*?"\/>)/', $v['content'], $matches);
		var_dump($matches[0]);
		if ($matches[0]) {
			print_r($v);
			print_r('------------------------------');
			foreach($matches[0] as $nk => $nv) {
				$v['content'] = str_replace($nv, '', $v['content']);
			}
			$content = $v['content'];
			$sql = "update xd_manual_data set content='{$content}' where itemid={$v['itemid']}";
			$db->query($sql);
		}
	}
	$start = $v['itemid'];
}

echo  '<meta http-equiv="refresh" content="1; url='.$_SERVER['PHP_SELF'].'?start='.$start.'&end='.$end.'" />';
